package com.hitfm.iplay;

import android.app.Application;
import android.database.Cursor;

import com.hitfm.iplay.tab.AnimationTabHost;

public class MusicPlayerApp extends Application {
	private MusicInfoController mMusicInfoController = null;
	private AnimationTabHost mTabHost = null;
	private static Cursor mCursor = null;
	private static MusicPlayerService mMusicPlayerService = null;

	public void onCreate() {
		super.onCreate();

		mMusicInfoController = MusicInfoController.getInstance(this);
	}

	public MusicInfoController getMusicInfoController() {
		return mMusicInfoController;
	}

	public AnimationTabHost getTabHost() {
		return mTabHost;
	}

	public void setTabHost(AnimationTabHost mTabHost) {
		this.mTabHost = mTabHost;
	}

	public Cursor getCursor() {
		return mCursor;
	}

	public Cursor getAllCursor() {
		initCursor();
		return mCursor;
	}

	public void setCursor(Cursor mCursor) {
		closeCursor();
		MusicPlayerApp.mCursor = mCursor;
	}

	public void initCursor() {
		closeCursor();
		mCursor = mMusicInfoController.getAllSongs();
	}

	public void closeCursor() {
		if (mCursor != null) {
			mCursor.close();
			mCursor = null;
		}
	}

	public static MusicPlayerService getmMusicPlayerService() {
		return mMusicPlayerService;
	}

	public static void setmMusicPlayerService(MusicPlayerService mMusicPlayerService) {
		MusicPlayerApp.mMusicPlayerService = mMusicPlayerService;
	}

	public void setFolderCursor(String url) {
		closeCursor();
		mCursor = mMusicInfoController.getAllSongFolder(url);
	}
	
	public void setArtistCursor(String artist) {
		closeCursor();
		mCursor = mMusicInfoController.getAllSongsByArtist(artist);
	}

}
